using System;
using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
using System.Collections.Generic;
using TienTeTuong;
using log4net;

namespace TienTeTuong
{
	/// <summary>
	/// Data access layer class for Feedback
	/// </summary>
	class FeedbackDAO {

        public void AddFeedback(FeedbackDTO feedbackDto)
        {
            MySqlConnection SqlConnection = null;
            MySqlCommand MysqlCmd = null;
            MySqlDataReader reader = null;
           
            try
            {

                SqlConnection = new MySqlConnection(Global.ConnectionString);
                if (SqlConnection.State == ConnectionState.Closed)
                    SqlConnection.Open();
                MysqlCmd = new MySqlCommand { Connection = SqlConnection };

                string strSQL = @"INSERT INTO Feedback VALUES ('" + feedbackDto.ID + "',";
                        strSQL += "'" + feedbackDto.Fullname + "',";
                strSQL += "'" + feedbackDto.Email + "',";
                strSQL += "'" + feedbackDto.Phone + "',";
                strSQL += "'" + feedbackDto.Company + "',";
                 strSQL += "'" + feedbackDto.Content + "',";
                 strSQL += "" + feedbackDto.Active + ",";
                 strSQL += "" + feedbackDto.Status + ",";
                 strSQL += "NOW()";
                       strSQL +=")";
               
                MysqlCmd.CommandText = strSQL;

                MysqlCmd.ExecuteNonQuery();
            
                //reader.Close();
                MysqlCmd.Dispose();
                SqlConnection.Close();
                SqlConnection.Dispose();
               

            }
            catch (Exception ex)
            {
                //if (reader != null) reader.Close();
                if (MysqlCmd != null)
                    MysqlCmd.Dispose();
                if (SqlConnection == null) return;
                SqlConnection.Close();
                SqlConnection.Dispose();
            }
        }
        
	}
}
